import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import set from '@dfeidao/atom-mobile/local/set';
import show_sheet from '@dfeidao/atom-mobile/msgbox/action-sheet';
import render from '@dfeidao/atom-mobile/render/render';

/**
 * 所属学生
 * @param fd
 * @param e
 * @param arr 学生
 */
export default async function a002(fd: IFeidaoAiMobile, e: Element, arr: string[]) {
	// console.log(arr);
	const data = get(fd, 'data') as [{ class_id: string, class_name: string, grade: string }];

	const options = new Array();
	for (let i = 0; i < arr.length; i++) {
		const text = arr[i];
		options.push(text);
	}
	const res = await show_sheet({
		options,
		title: '选择所属学生'
	});
	const data_obj = data[res];
	// console.log(data_obj, '-----当前选择的学生数据------');
	if (!data_obj) {
		return;
	}
	set(fd, 'obj', data_obj);

	render(fd, { index: res });
}
